package com.example.sell.dataobject;

import com.example.sell.enums.ProductStatusEnum;
import com.example.sell.utils.EnumUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Data
@DynamicUpdate//同步数据库时间
public class ProductInfo {
    @Id
    private String productId;
    //名字
    private String productName;
    //价格
    private BigDecimal productPrice;
    //库存
    private Integer productStock;
    //描述
    private String productDescription;
    //小图
    private String productIcon;
    //状态，0正常，1下架
    private Integer productStatus=ProductStatusEnum.UP.getCode();
    /** 类目编号。*/
    private Integer categoryType;
    private Date createTime;
    private Date updateTime;
    @JsonIgnore//忽略返回
    public ProductStatusEnum getProductStatusEnum(){
        return EnumUtil.getByCode(productStatus,ProductStatusEnum.class);
    }
}
